<template>
  <div>
    <city-header></city-header>
    <city-search :cities="cities" @inputStatus="changeLetterStatus"></city-search>
    <city-list :cities="cities" :hotCities="hotCities" :letter="letter"></city-list>
    <city-alphabet :cities="cities" :isShow="isShowLetter" @change="reLetterChange"></city-alphabet>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './components/header'
import CitySearch from './components/search'
import CityList from './components/list'
import CityAlphabet from './components/alphabet'
export default {
  naem: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      cities: {},
      hotCities: [],
      letter: 'A',
      isShowLetter: true
    }
  },
  methods: {
    getCityInfo () {
      axios.get('api/city.json').then(res => {
        const data = res.data.data
        this.cities = data.cities
        this.hotCities = data.hotCities
      })
    },
    reLetterChange (letter) {
      this.letter = letter
    },
    changeLetterStatus (status) {
      this.isShowLetter = status
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>

<style lang="stylus" scoped>
</style>
